home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
-
- Created: Friday, March 24, 1995 at 3:12:00 PM
- somcmpat.h
-
- System Object Model
- Macintosh Version
-
- © International Business Machines Corp. 1992-1994
- © Apple Computer, Inc. 1994-1995
- All rights reserved
-
- ************************************************************/
-
-
- #ifndef __SOMCMPAT__
- #define __SOMCMPAT__
-
- #include <som.h>
-
- #if __IBM_TO_MAC__
-
- /*
- *
- * The compatibility header for porting code from the standard
- * SOM API to the modern SOM APIs. This file defines older API
- * functions as macros so that their use does not cause
- * compile time errors. Given no changes to the ported
- * source code, these macros implement the best possible equivalent
- * in terms of the existing APIs.
- *
- */
-
- /* included by som.h */
-
- typedef char integer1;
- typedef short integer2;
- typedef unsigned short uinteger2;
- typedef long integer4;
- typedef unsigned long uinteger4;
- typedef float float4;
- typedef double float8;
- typedef char *zString; /* NULL terminated string */
- typedef char *fString; /* non-terminated string */
- typedef corbastring string;
-
- /* define private macro to obtain class object */
- #ifdef __cplusplus
- #define SOM_GetClass(obj) \
- ( ( obj ) -> somGetClass () )
- #else
- #define SOM_GetClass(obj) \
- _somGetClass ( obj )
- #endif
-
- /* define the class manager global */
- SOMEXTERN SOMClassMgr SOMSTAR SOMClassMgrObject;
-
- /* add dual usage for somEnvironmentNew */
- #define somEnvironmentNew() (somEnvironmentNew(),SOMClassMgrObject)
-
- #define somWriteMetrics(fp,z) ((void) ((fp),(z)))
- #define somSaveMetrics() ((void) 0)
- #define somPrintNameSpace() ((void) 0)
-
- /* -------------------------------------------------------------------
- * The following macros are for purposes of backward compatibility
- * with prior versions of SOM. There is no advantage to using them
- * over a direct call to the corresponding routine.
- */
-
- #define SOM_CompareValidIds(id1,id2) \
- (somCompareIds(id1,id2))
-
- #define SOM_CompareIds(id1,id2) \
- (somCompareIds(id1,id2))
-
- #define SOM_IdFromString(str) \
- somIdFromString(str)
-
- #define SOM_StringFromId(id) \
- somMakeStringFromId(id)
-
- #define SOM_CheckId(id) \
- (somCheckId(id))
-
- #ifdef __cplusplus
- #define SOM_SubstituteClass(old,new) \
- SOMClassMgrObject -> somSubstituteClass \
- ( _##old->somGetName (), _##new->somGetName ());
-
-
- #else
- #define SOM_SubstituteClass(old,new) \
- _somSubstituteClass ( SOMClassMgrObject, \
- _somGetName (_##old), _somGetName (_##new));
- #endif
-
- #elif __MAC_TO_IBM__
-
- /*
- *
- * The compatibility header for porting code from the modern
- * SOM API to other SOM APIs. This file defines newer API
- * functions as macros so that their use does not cause
- * compile time errors. Given no changes to the underlying
- * kernel, these macros implement the best possible equivalent
- * in terms of the existing APIs.
- *
- */
-
- /* included by som.h */
- #include <string.h>
-
-
- /* === ID Section === */
-
- /* a "somKernelId" is a kernel owned "somId" and can be
- converted to a "somId" using the functions below */
- typedef somId somKernelId;
-
- /* converts a "somKernelId" into a "somId" which must
- later be freed by "SOMFree" */
- #define somConvertAndFreeKernelId(kernelId) \
- somIdFromString ( somStringFromId ( (somId) ( kernelId ) ) )
-
- /* frees a "somKernelId" on kernels which don't maintain
- internal string databases */
- #define somFreeKernelId(kernelId) \
- ( (void) ( kernelId ) )
-
- /* creates a user owned "SOMMalloc'd" copy of the id string
- which must later be freed by "SOMFree" */
- #define somMakeStringFromId(id) \
- strcpy ( (char*) SOMMalloc ( strlen ( somStringFromId ( id ) ) + 1 ), \
- somStringFromId ( id ) )
-
-
- /* === Dynamic Loading / Unloading Section === */
-
- /* the API to obtain a static class object reference */
- #define somNewClassReference(cls) \
- ( cls ## NewClass ( cls ## _MajorVersion, cls ## _MinorVersion ) )
-
- /* the API to obtain a static class reference that allows use of
- version numbers other than the compile time current ones */
- #define somNewVersionedClassReference(cls,majorVersion,minorVersion) \
- ( cls ## NewClass ( majorVersion, minorVersion ) )
-
- /* the API to get a dynamic reference w/o using the class manager */
- #ifdef __cplusplus
- #define somGetDynamicClassReference(classId,majorVersion,minorVersion,file) \
- ( ( file ) ? SOMClassMgrObject -> somFindClsInFile (classId, majorVersion, minorVersion, file) :
- SOMClassMgrObject -> somFindClass (classId, majorVersion, minorVersion) )
- #else
- #define somGetDynamicClassReference(classId,majorVersion,minorVersion,file) \
- ( ( file ) ? _somFindClsInFile ( SOMClassMgrObject, classId, majorVersion, minorVersion, file) :
- _somFindClass ( SOMClassMgrObject, classId, majorVersion, minorVersion) )
- #endif
-
- /* the API to release a class reference w/o destroying the class from other users */
- #define somReleaseClassReference(classObject) \
- ( (void) ( classObject ) )
-
- /* === Automatic Object Allocation Section === */
- #ifdef __cplusplus
- #define somGetInstanceSizeAndStaticClassReference(cls,majorVersion,minorVersion,classObj) \
- (( *classObj = cls ## NewClass ( majorVersion, minorVersion ) ) -> somGetInstanceSize ())
- #else
- #define somGetInstanceSizeAndStaticClassReference(cls,majorVersion,minorVersion,classObj) \
- _somGetInstanceSize ( *classObj = cls ## NewClass ( majorVersion, minorVersion ) )
- #endif
-
- #ifdef __cplusplus
- #define somInitInstanceAndFreeClassReference(classObject,addr) \
- ( ( classObject ) -> somRenew ( addr ) )
- #else
- #define somInitInstanceAndFreeClassReference(classObject,addr) \
- _somRenew ( classObject, addr )
- #endif
-
- #ifdef __cplusplus
- #define somDestructAutoObject(obj) \
- ( ( obj ) -> somUninit () )
- #else
- #define somDestructAutoObject(obj) \
- _somUninit ( obj )
- #endif
-
-
- /* === Class Manager Section === */
-
- /* the API to obtain a reference to the class manager */
- #define somGetClassManagerReference() \
- SOMClassMgrObject
-
- /* the API to release a reference to a class manager object */
- #define somReleaseClassManagerReference(classMgrObj) \
- ( (void) ( classMgrObj ) )
-
-
- /* === Init / Term Section === */
-
- /* the API to inform SOM of the existance of a class w/o obtaining
- a reference to the class object */
- #define somNewClass(cls) \
- (( void ) cls ## NewClass ( cls ## _MajorVersion, cls ## _MinorVersion ))
-
- /* the API to inform SOM of the impending demise of a class
- (ie: the code for it is about to be unloaded) */
- #define somKillClass(cls) /* ignore */
-
-
- /* === Object Creation Section === */
-
- /* the API to obtain a new instance object w/o having
- to deal with the class object */
- #ifdef __cplusplus
- #define somNewObject(cls) \
- new cls
- #else
- #define somNewObject(cls) \
- cls ## New()
- #endif
-
- /* the API to obtain a new instance object w/o having
- to deal with the class object, but with version
- checking other than the compile time current numbers */
- #ifdef __cplusplus
- #define somNewVersionedObject(cls, majorVersion, minorVersion) \
- ((cls SOMSTAR) (( cls ## NewClass ( majorVersion, minorVersion ) ) \
- -> somNew ()))
- #else
- #define somNewVersionedObject(cls, majorVersion, minorVersion) \
- ((cls SOMSTAR) _somNew ( cls ## NewClass ( majorVersion, minorVersion ) ))
- #endif
-
- #ifdef __cplusplus
- inline SOMObject SOMSTAR somNewObjectById ( somId classId,
- long majorVersion, long minorVersion )
- {
- SOMClass SOMSTAR classObj = SOMClassMgrObject -> somFindClass
- ( classId, majorVersion, minorVersion );
- return classObj ? classObj -> somNew () : NULL;
- }
- #else
- static SOMObject SOMSTAR somNewObjectById ( somId classId,
- long majorVersion, long minorVersion )
- {
- SOMClass SOMSTAR classObj = _somFindClass ( SOMClassMgrObject,
- classId, majorVersion, minorVersion );
- return classObj ? _somNew ( classObj ) : NULL;
- }
- #endif
-
- static SOMObject SOMSTAR somNewObjectByName ( corbastring className,
- long majorVersion, long minorVersion )
- {
- SOMObject SOMSTAR obj = NULL;
- somId classId = somIdFromString ( className );
- if ( classId ) {
- obj = somNewObjectById ( classId, majorVersion, minorVersion );
- SOMFree ( classId );
- }
- return obj;
- }
-
- #define somDuplicateReference(obj) \
- ((SOMObject SOMSTAR) (obj))
-
- #define somCompareReference(ob1j,obj2) \
- ((void *) (obj1) == (void *) (obj2))
-
- /* the API to release a reference to an object w/o
- destroying the object for others that are using it */
- #if RELEASE_MEANS_FREE
- #ifdef __cplusplus
- #define somReleaseObjectReference(obj) \
- (( obj ) -> somFree ())
- #else
- #define somReleaseObjectReference(obj) \
- ( _somFree ( obj ) )
- #endif
- #else
- #define somReleaseObjectReference(obj) \
- ( (void) ( obj ) )
- #endif
-
- #endif /* __MAC_TO_IBM__ */
-
- #endif /* __SOMCMPAT__ */
-